var fakedata=require("../../static/js/fakedata");
var app=getApp();
Page({
    data: {
        hidden:true,
        value:'',
        commentid:'',
        article:[
            {
                id:1,
                username:"小明",
                AvatarUrl:"../../static/images/article/Avatars/Avatar1.jpg",
                time:"一个月前",
                content:"hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh",
                pictureUrl:"../../static/images/article/picture/article_picture1.jpg",
            },
            {
                id:2,
                username:"放牛的孩子",
                AvatarUrl:"../../static/images/article/Avatars/Avatar2.jpg",
                time:"昨天",
                content:"天上有片云",
                pictureUrl:"../../static/images/article/picture/article_picture2.jpg",
            },
            {
                id:3,
                username:"河边青青草",
                AvatarUrl:"../../static/images/article/Avatars/Avatar3.jpg",
                time:"昨天",
                content:"我今天很开心心心心心111111111111111111111111111111111111111111111111111111111111111",
                pictureUrl:"../../static/images/article/picture/article_picture3.jpg",
            }

        ],
        more:'../../static/images/more.png'
    },
    onLoad(){
    },
    onShow(){
        swan.request({
            url: fakedata.urls.getallforum,
            header: {
                'Content-Type': 'application/json',
                'Developer-Server-Domain': fakedata.host,
                'X-SP-Accept-Encoding': 'base64'
            },
            method: 'GET',
            dataType: 'json',
            responseType: 'text',
            data: {
                number:50
            },
            success: res => {
                console.log(res);
                // 这里读取列表
            },
            fail: err => {
                swan.showModal({
                    title: '错误信息',
                    content: JSON.stringify(err)
                });
            }
        });
    },
    display(e){
        if(this.data.hidden){
            this.setData({
                hidden:!this.data.hidden,
                commentid:e.currentTarget.dataset.commentid
            });

        }else{
            this.setData({
                hidden:!this.data.hidden,
                value:''
            });
        }
    },
    comment(){
        console.log(this.data.value);
        swan.showModal({
            title: '提交的信息',
            content: this.data.value
        });
        this.setData({
            hidden:!this.data.hidden,
            value:''
        });
    },
    updateData(e){
        this.setData({
            value:e.detail.value
        });
    }
});